package org.itboys.weixin.controller;

import org.itboys.admin.entity.lasted.SystemDictionary;
import org.itboys.admin.service.lasted.SystemDictionaryService;
import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.mobile.dto.SundayAdvertisementDto;
import org.itboys.mobile.entity.mongo.SundayMember;
import org.itboys.mobile.service.mongo.weixin.member.SundayWeixinMemberService;
import org.itboys.weixin.service.WeixinConfigService;
import org.itboys.weixin.service.WeixinTwoCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * 作者：zzq
 * 时间：2017/11/1
 * 描述：雄安加盟网_
 */
@Controller
@RequestMapping("/sunday/weixin/share")
public class SundayWeixinShareController extends BaseController {
    @Autowired
    private WeixinTwoCodeService codeService;
    @Autowired
    private SundayWeixinMemberService memberService;
    @Autowired(required = false)
    private WeixinConfigService weixinConfigService;
    @Autowired
    private SystemDictionaryService dictionaryService;
    @RequestMapping("/index")
    public String index(
            HttpServletRequest request,
            @RequestParam(value="memberId",required = true) Long memberId,
            Model model){
        SundayMember memberDto=memberService.getById(memberId);
        if(LongUtil.isNull(memberDto.getRecommendId())){
            return "/newcoo/weixin/doLogin";
        }
        model.addAttribute("memberDto",memberDto);
        String image=codeService.createSceneTwoCode(1l,memberId);
        model.addAttribute("image",image);

        return "/newcoo/weixin/share";
    }
}
